package aswerGenerator;

import lexicalUnit.Environ;
import lexicalUnit.LexicalException;

public class AnsGenerator {
	
	String answer;
	Environ env;
	GetAnswerData ans;
	
	public AnsGenerator (Environ env){
		this.env = env;
		ans = new GetAnswerData(env);
	}

	//Checks environ information to generate the answer
	public String generateAnswerInfo() throws NotFoundInDatabaseException{
		//System.err.println("keyword " + env.getKeyword() + " target: " + env.getTarget() + " keywordclass " + env.getKeywordClass());
		if (env.getKeyword()==null)
			 ans.fetchAll();
		if (env.getYnkeyword()!=null)
			System.err.println("ynkeyword: " + env.getYnkeyword());
		switch (env.getTarget()){
		case Environ.PLACE:
			return ans.fetchPlace();
		case Environ.PERSON:
			return ans.fetchPerson();
		case Environ.COURSE:
			return ans.fetchCourse();
		case Environ.PROGRAM:
			return ans.fetchProgram();
		case Environ.ROOM:
			return ans.fetchRoom();
		case Environ.PERIOD:
			return ans.fetchPeriod();
		case Environ.BUILDING:
			return ans.fetchBuilding();
		case Environ.MANDATORY_COURSE:
			return ans.fetchMandatoryCourse();
		case Environ.OPTIONAL_COURSE:
			return ans.fetchOptionalCourse();
		case Environ.CODE:
			return ans.fetchCode();
		case Environ.THING:
			return ans.fetchThing();
		case Environ.LEVEL:
			return ans.fetchLevel();
		case Environ.COUNT:
			return ans.fetchCount();
		}
		throw new LexicalException("Answer genarator cannot asnwer this question");
	}


}
